package xyz.xiezc.spider;

import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.db.Entity;
import cn.hutool.db.Session;
import cn.hutool.setting.Setting;
import lombok.extern.slf4j.Slf4j;
import xyz.xiezc.ioc.XIoc;
import xyz.xiezc.ioc.annotation.ComponentScan;
import xyz.xiezc.ioc.annotation.Inject;
import xyz.xiezc.spider.control.ScheduleImpl;

/**
 * @author wb-xzc291800
 * @date 2019/04/08 9:17
 */
@Slf4j
@ComponentScan("xyz.xiezc.xhttp.HttpServer")
public class App extends XIoc {

    @Inject
    ScheduleImpl schedule;
    @Inject
    Setting setting;


    public static void main(String[] args) {
        App app = new App();
        app.schedule.addCommonHeader("User-Agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1");
        log.info("初始化.............................");

        Integer anInt = app.setting.getInt("static.server.port");
        app.schedule
                .addSeedUrls(
                        "https://www.mzitu.com/all/",
                        "https://www.mzitu.com/xinggan/",
                        "https://www.mzitu.com/hot/",
                        "https://www.mzitu.com/zipai/comment-page-1/"
                        ,
                        "https://www.mzitu.com/best/",
                        "https://www.mzitu.com/taiwan/",
                        "https://www.mzitu.com/mm/",
                        "https://www.mzitu.com/japan/"
                )
                .startHttp(anInt, ThreadUtil.newExecutor(5));
    }
}
